package com.siwei.mes.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.siwei.mes.mapper.HomeMapper;
import com.siwei.mes.service.HomeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static cn.dev33.satoken.SaManager.log;

/**
 * @program: mes-platform
 * @description:
 * @author: yangke
 * @create: 2024-01-01 17:59
 **/
@Service
public class HomeServiceImpl implements HomeService {
    @Resource
    private HomeMapper homeMapper;

    @Override
    public Map homeAnalysis() {
        String userId = StpUtil.getLoginIdAsString();
        Map<String,Object> result = new HashMap();
        /*试验分析*/
        try {
            result.put("experimentAnalysis",homeMapper.experimentAnalysis(userId));
        }catch (Exception e) {
            log.error("试验分析异常>>>>>>>>>>>", e);
        }
        /*工单分析*/
        try {
            result.put("orderAnalysis",homeMapper.orderAnalysis(userId));
        }catch (Exception e) {
            log.error("试验分析异常>>>>>>>>>>>", e);
        }
        /*强度波动分析*/
        try {
            result.put("intensityFluctuationsAnalysis", new HashMap());
        }catch (Exception e) {
            log.error("强度波动分析异常>>>>>>>>>>>", e);
        }
        /*采购预估*/
        try {
            result.put("purchaserPredict",homeMapper.purchaserPredict());
        }catch (Exception e) {
            log.error("采购预估异常>>>>>>>>>>>", e);
        }
        /*工单趋势分析*/
        try {
            result.put("orderTrendAnalysis",homeMapper.orderTrendAnalysis());
        }catch (Exception e) {
            log.error("工单趋势分析异常>>>>>>>>>>>", e);
        }
        /*工单类型分析*/
        try {
            result.put("workOrderTypeAnalysis",homeMapper.workOrderTypeAnalysis());
        }catch (Exception e) {
            log.error("工单类型分析异常>>>>>>>>>>>", e);
        }
        return result;
    }

    @Override
    public Map experimentAnalysis() {
        String userId = StpUtil.getLoginIdAsString();
        return homeMapper.experimentAnalysis(userId);
    }

    @Override
    public Map orderAnalysis() {
        String userId = StpUtil.getLoginIdAsString();
        return homeMapper.orderAnalysis(userId);
    }

    @Override
    public List<Map> intensityFluctuationsAnalysis() {
        return null;
    }

    @Override
    public  List<Map> purchaserPredict() {
        return null;
    }

    @Override
    public List<Map> orderTrendAnalysis() {
        return homeMapper.orderTrendAnalysis();
    }

    @Override
    public List<Map> workOrderTypeAnalysis() {
        return homeMapper.workOrderTypeAnalysis();
    }
}
